{include file="Index/header" /}
<body>
<div class="formbody">
	<div class="formtitle"><span>友情链接管理</span></div>
	<form action="Advert/index" method="post" id="pic_form"> 
			<table class="imgtable" >
				<thead>
					<tr>
						<th>编号</th>
						<th width="100px;">链接图片</th>
						<th>跳转地址</th>
						<th width="200px;">展示状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="t_body">
				 	{volist name="listArr" id="vo" key="k" } 
					<tr>
						<td>{$vo.id}</td>
						<td>
							<img src="__UPLOAD__{$vo.logo}" width="100"   />
						</td>
						<td>{$vo.url}</td>
						<td id="act_{$vo.id}">
							{if $vo['status']=="1"}
								<font color=green>开启</font>
							{else /}
								<font color=red>禁止</font> 
							{/if}
						</td>
						<td>
							<a class="tablelink" href="{:url('Link/add',['lid'=>$vo['id']])}" onclick="deleteItem(this);">编辑</a>
							<a class="tablelink" href="{:url('Link/delete',['lid'=>$vo['id']])}" >删除</a>
							{if $vo[status]== '1'}
								<span id="set_status_{$vo.id}"><a href="javascript:void(0);" class="tablelink" onclick="is_act({$vo.id},2);">禁止</a></span>
							{else /}
								<span id="set_status_{$vo.id}"><a href="javascript:void(0);" class="tablelink" onclick="is_act({$vo.id},1);">开启</a></span>
							{/if}
						</td>
					</tr>
				 	{/volist}
				</tbody>
			</table>
	</form>
</div>
<script>
	//激活或冻结
	function is_act(link_id,status){
		$.post("{:url('Link/setstatus')}",{
			'link_id':link_id,
			'status':status
		},function(json){
			if(json.data=="1"){
				$("#act_"+link_id).html('<span style="color:green;" class="status">开启</span>');
				$("#set_status_"+link_id).html('<a href="javascript:void(0);" class="tablelink" class="set_status" onclick="is_act('+link_id+',2);">禁止</a>');
			}else{
				$("#act_"+link_id).html('<span style="color:red;" class="status">禁止</span>');
				$("#set_status_"+link_id).html('<a href="javascript:void(0);" class="tablelink" class="set_status" onclick="is_act('+link_id+',1);">开启</a>');
			}
		},'json');
	}

	/* 删除用户信息 */
	function del(obj_id){
		$.post("{:url('Link/delete')}",{
			'link_id':obj_id
		},function (json){
			if(json.status == "1"){
				$("#tr_"+obj_id).remove();
			}else{
				alert("删除失败");
			}
		},'json');
	}
</script>

{include file="Index/footer" /}